package cn.stacey.day10;

import java.io.File;
import java.io.IOException;

import org.junit.Test;

public class DemoFile {

	
	public static void main(String[] args) throws IOException {
		File file = new File("test.java");	
		file.createNewFile();
		System.out.println(file.getAbsolutePath());	// 获取绝对路径
	}
	@Test
	public void test() throws IOException {
		File directory=new File("D://");
		File file=new File(directory, "test1.java");
		boolean isCreated=file.createNewFile();
		System.out.println(isCreated);
	}
	
	@Test
	public void testDirectory() {
		File dir=new File("D://test");
		boolean isCreated=dir.mkdirs();
		System.out.println(isCreated);
	}
	
	@Test
	public void test1() throws IOException {
		File dir1=new File("D:\\test5");
		dir1.mkdirs();
		//在一个文件夹中创建文件
		File f=new File(dir1, "123.txt");
		f.createNewFile();
		System.out.println(dir1.getAbsolutePath());
		f.delete();
		dir1.delete();
		dir1.getParentFile().delete();
	}
	
}
